package com.hunau.novel_reading.controller;

import com.hunau.novel_reading.common.R;
import com.hunau.novel_reading.request.BooksSeekReq;
import com.hunau.novel_reading.service.BooksService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/books")
public class BooksController {
    @Resource
    private BooksService booksService;

    @GetMapping("/getBooks")
    public R getBooks()
    {
        System.out.println("getbooks");
        return R.ok().data("books",booksService.getBooks());
    }
    @PostMapping("/getBooksByBookNameOrType")
    public R getBooksByBookNameOrType(@RequestBody @Valid BooksSeekReq booksSeekReq)
        {
            return R.ok().data("books",booksService.getBooksByBookNameOrType(booksSeekReq));
        }
    @PostMapping("/selectBookByBookId")
    public R selectBookByBookId(@RequestBody @Valid com.hunau.novel_reading.request.BooksSeekByBookId booksSeekByBookId)
        {
            return R.ok().data("book",booksService.selectBookByBookId(booksSeekByBookId));
        }
}
